#include <iostream>
#include <ctime>
#include <cstdlib>
#include "AltLRU.hpp"

using namespace std;

#define SRAND 1234567
/*
No mempool:
Timing[1000000,1000000] = 1510000
Timing[1000000,100000] = 1450000
Timing[100000,1000000] = 140000
Timing[100000,100000] = 130000
Timing[100000,100] = 110000
Timing[10000,10] = 10000
Timing[1000,5] = 0
Timing[100,100] = 0
Timing[10,10] = 0
real0m4.383s
user0m3.952s
sys0m0.376s

Timing[1000000,1000000] = 1490000
Timing[1000000,100000] = 1510000
Timing[100000,1000000] = 140000
Timing[100000,100000] = 140000
Timing[100000,100] = 110000
Timing[10000,10] = 20000
Timing[1000,5] = 0
Timing[100,100] = 0
Timing[10,10] = 0

real0m4.416s
user0m3.940s
sys0m0.456s


*/
int main() {
	size_t tests[] = {
		1000000, 1000000,
		1000000, 100000,
		100000,  1000000,
		100000, 100000,
		100000, 100,
		10000, 10,
		1000, 5,
		100, 100,
		10, 10
		};
	clock_t c1, c2;

	for(int t=0; t<sizeof(tests)/sizeof(tests[0]); t+=2 ) {
		AltLRU<int> lru( tests[t+1] );
		srand( SRAND );
		
		c1 = clock();
		for(size_t i=0; i<tests[t]; i++) {
			int rnd = rand()%tests[t+1];
			lru.set("test", rnd, 1, 1);
			lru.get("test", rnd);
		}
		c2 = clock();
		cout << "Timing[" << tests[t] << "," << tests[t+1] << "] = " << c2-c1 << endl;
	}

	return 0;
}
